//
//  SVTextEditViewController.m
//  ShortVideo-ccinon
//
//  Created by LIN TONG on 2017/6/27.
//  Copyright © 2017年 LIN TONG. All rights reserved.
//

#import "SVTextEditViewController.h"
#import "SVConfig.h"
#import "QRCodeUtil.h"
#import "SVNavigationBar.h"

@interface SVTextEditViewController ()<UITextViewDelegate>{
    UITextView *textView;
}

@end

@implementation SVTextEditViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = UIColorMake(239, 239, 239, 1);
    // Do any additional setup after loading the view.
    
    SVNavigationBar *naviBar = [[SVNavigationBar alloc]init];
    [naviBar setBackHander:^{
        [self.navigationController popViewControllerAnimated:YES];
    }];
    [naviBar setDoneHandler:^{
        if(self.doneHandler){
            NSString *text = @"";
            if(textView.text.length > 0){
                text = textView.text;
            }
            self.doneHandler(text);
        }
        [self.navigationController popViewControllerAnimated:YES];
    }];
    [naviBar setTitle:@"编辑文本"];
    naviBar.showBackButton = YES;
    naviBar.showDoneButton = YES;
    [self.view addSubview:naviBar];
    
    textView = [[UITextView alloc]initWithFrame:CGRectMake(0, S(7)+CGRectGetMaxY(naviBar.frame), __SCREEN_WIDTH__, S(184))];
    [textView becomeFirstResponder];
    textView.backgroundColor = [UIColor whiteColor];
    textView.font = Font(13);
    textView.returnKeyType = UIReturnKeyDone;
    [self.view addSubview:textView];
    
    if(self.text){
        textView.text = self.text;
    }
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (UIStatusBarStyle)preferredStatusBarStyle{
    return UIStatusBarStyleLightContent;
}

@end
